
import pygame
import battleScreen
#import pokemon
#import move
#import button

screen = pygame.display.set_mode([512, 288])
battlescreen = pygame.Surface([256, 144])

pygame.init()

ATTACK = 2####################################################

BLACK = [0, 0, 0]
WHITE = [255, 255, 255]

animationFrames = [10, 17, 23, 10, 30, 17, 17, 11, 14, 11, 11, 4, 4, 13, 4]
animationHeight = [144, 191, 191, 144, 144, 191, 144, 191, 191, 144, 191, 191, 133, 191, 32]
animationHeightv2 = [144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 32]
animationWidth = [256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 32]
animationRow = [10, 17, 23, 4, 30, 17, 17, 11, 14, 11, 11, 4, 4, 13, 4]
animationCollumn = [1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

animation = ['FIRE-BLAST-1', 'HYDRO-CANNON-2', 'SHADOW-BALL-1', 'Seed-Flare', 'SURFV2', 'MUD-SHOT-1', 'AEROBLAST-1', 'SWIFT-1', 'HYDRO-PUMP-1', 'FRENZY-PLANT-1', 'BLAST-BURN-1', 'WOOD-HAMMER-1', 'ROCK-SMASH-1', 'MUDSPORT', 'THUNDAR']
animationBackground = ['fireblastybackground', 'Hydro-cannon-back', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'AeroBlastBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground']

animationColor = [BLACK, WHITE, WHITE, WHITE, WHITE, WHITE, BLACK, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, BLACK]

attackImage = pygame.image.load('../images/attackAnimations/' + animation[ATTACK] + '.bmp').convert()
attackBackground = pygame.image.load('../images/attackAnimations/' + animationBackground[ATTACK] + '.png')

backgroundImage = pygame.image.load("../images/BattleBackgrounds/background.png")
secondBackgroundImage = pygame.image.load("../images/BattleBackgrounds/sprite5.png")

attackSprite = []
flippedAttack = []
for ROW in range(animationRow[ATTACK]):
    for COLLUMN in range(animationCollumn[ATTACK]):
        nextFrame = pygame.Surface((animationWidth[ATTACK], animationHeightv2[ATTACK]))
        nextFrame.blit(attackImage, (0,0), (COLLUMN * animationWidth[ATTACK], ROW * animationHeight[ATTACK], COLLUMN * animationWidth[ATTACK] + (animationWidth[ATTACK] - 1), ROW * animationHeight[ATTACK] + (animationHeight[ATTACK] - 1)))
        nextFrame.set_colorkey(animationColor[ATTACK])
        attackSprite.append(nextFrame)
#        flippedNextFrame = pygame.transform.flip(nextFrame, True, True)
#        flippedAttack.append(flippedNextFrame)
        if len(attackSprite) == animationFrames[ATTACK]:
            break
    if len(attackSprite) == animationFrames[ATTACK]:
        break
    
frame = 0
clock= pygame.time.Clock()
delay = 0
attacking = True
while True:
    for i in pygame.event.get():
        if i.type == pygame.QUIT:
            pygame.quit()
            quit()
    screen.blit(battlescreen, (0, 0))
    battlescreen.blit(backgroundImage, (0,0))
    battlescreen.blit(secondBackgroundImage, (0, 0))
    if attacking == True:
#        attackBackground1 = pygame.transform.flip(attackBackground, True, True)
#        flippd = pygame.transform.flip(attackSprite[frame], True, True)
#        battlescreen.blit(flippd, (0, 0))
        if ATTACK == 0 or ATTACK == 1 or ATTACK == 3:
#            attackBackground1 = pygame.transform.flip(attackBackground, True, True)
#            flippd = pygame.transform.flip(attackSprite[frame], True, True)
#            battlescreen.blit(flippd, (0, 0))
            battlescreen.blit(attackBackground1, (0, 0))
            battlescreen.blit(attackSprite[frame], (0, 0))
#            battlescreen.blit(flippedAttack[frame, (0, 0)])
            
        elif ATTACK == 14:
            battlescreen.blit(attackSprite[frame], [(192 - (attackSprite[frame].get_size()[0] / 2 )), (80 - (attackSprite[frame].get_size()[1]))])
            attackSprite[frame] = pygame.transform.scale2x(attackSprite[frame])
            
        else:
            battlescreen.blit(attackSprite[frame], (0,0))
            
    pygame.display.flip()
    
    if delay == 0:
        frame += 1
    delay += 1
    delay %= 2
    if ATTACK == 2:
        clock.tick(20)
    elif ATTACK == 14:
        clock.tick(8)
    else:
        clock.tick(15)
    if frame == animationFrames[ATTACK]:
        attacking = False
    frame %= animationFrames[ATTACK]


###########      0         1         2         3         4       5       6       7         8      9         10     11       12         13       14    15         16
#listMoves = ["normal", "fight", "flying", "poison", "ground", "rock", "bug", "ghost", "steel", "fire", "water", "grass", "electr", "psychc", "ice", "dragon", "dark"]
#for i in listMoves[:]:
#    if moveType == listMoves[9]:
#        animNum = 0
#    elif moveType == listMoves[10]:
#        animNum = 1
#    elif moveType == listMoves[7]:
#        animNum = 2
#    elif moveType == listMoves[6]:
#        animNum = 3 
#    elif moveType == listMoves[4] or moveType == listMoves[5] or moveType == listMoves[8]:
#        animNum = 5
#    elif moveType == listMoves[2]:
#        animNum = 6
#    elif moveType == listMoves[0]
#        animNum = 7
#    elif moveType == listMoves[11]:
#        animNum = 9
#    elif moveType == listMoves[12]:
#        animNum = 13








































